<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/* type_catalog: 1 booth, 2 ad, 3 company, 4 top1, 5 top2, 6 top3 */
class Bid_model extends CI_Model {

    public $table = 'bids';
    public $primary = 'id';

    function add($data) {
        $this->db->insert($this->table, $data);
    }

    function update($id, $data) {
        $this->db->where($this->primary, $id);
        return $this->db->update($this->table, $data);
    }

    function getAllBidByType($type) {
        $query = $this->db->query("SELECT companys.*
  	    							FROM {$this->table}
  	    							JOIN companys ON {$this->table}.user_id = companys.user_id
  	                                WHERE `type_catalog` = {$type}");
        return $query->result_array();
    }
    
    function getAllBidByUserId($user_id) {
        $query = $this->db->query("SELECT type_catalog 
  	    							FROM {$this->table}
  	                                WHERE `user_id` = {$user_id}");
        return $query->result_array();
    }
}